<template>
	<view>
		<view class="uni-column" v-if="summaryList!=null">
			<view class="bg-white solid padding margin-top" v-for="(item,index) in fmSummary" :key='index'>
				<view class="uni-row solid-bottom">
					<view class="flex uni-column justify-center">
						<view class="text-sm text-blue text-bold text-center">OKEX</view>
						<view class="cu-avatar lg round" :style="[{ backgroundImage:'url(' + item.photo + ')' }]">
							<view class="cu-tag badge cuIcon-vip bg-yellow"></view>
						</view>
					</view>
					<view class="flex-twice uni-column margin-left-lg">
						<view class="flex-sub text-sm  text-gray">该用户已将多空倍数隐藏</view>
						<view class="flex-treble text-xxl">{{item.nickname}}</view>
						<view class="flex-sub text-sm  text-gray">{{item.selfDesc}}</view>
					</view>
					<view class="flex align-center">
						<button class="cu-btn lines-orange text-orange text-center" v-if="item.isMySelf" @click="genDanConfirm(item.id)">我自己的</button>
						<button class="cu-btn lines-blue text-center" v-else-if="item.isMyOrdered" @click="genDanConfirm(item.id)">取消订阅</button>
						<button class="cu-btn lines-blue text-center" v-else-if="item.joinType=='everyone'" @click="genDanConfirm(item.id)">免费订阅</button>
						<button class="cu-btn lines-blue text-center" v-else-if="item.joinType=='bkb'" @click="genDanConfirm(item.id)">{{item.bkbCast}}BKB/月</button>
						<button class="cu-btn lines-blue text-center" v-else-if="item.joinType=='serial'" @click="genDanConfirm(item.id)">激活码订阅</button>
					</view>
				</view>
				<view class="uni-row">
					<view class="flex-sub text-center">
						<view class="text-df">${{item.currentBalance}}</view>
						<view class="text-sm text-grey">帐户资金</view>
					</view>
					<view class="flex-sub text-center">
						<view class="text-df" :class="item.earnRate>0?'text-green':'text-red'">{{item.earnRate}}%</view>
						<view class="text-sm text-grey">总收益率</view>
					</view>
					<view class="flex-sub text-center">
						<view class="text-df" :class="item.earn>0?'text-green':'text-red'">{{item.earn}}</view>
						<view class="text-sm text-grey">总收益额</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else class="padding-xl text-center bg-white solid-top">
			暂无实盘
		</view>
	</view>
</template>

<script>
	var _self
	export default {		
		props: {
			isLoginOn:false,
			summaryList: null
		},
		computed: {
			fmSummary: function() {
				if (this.summaryList != null) {
					let fmtSummary = this.summaryList
					for (let item of fmtSummary) {
						item.earn = Number(item.currentBalance-item.initBalance).toFixed(4)
						item.earnRate = Number(item.earn * 100 / item.initBalance).toFixed(2)
					}
					return fmtSummary
				}
				return null
			}
		},
		mounted() {
			_self = this;
		},
		methods: {
			genDanConfirm(id) {
				if(!_self.isLoginOn){
					uni.navigateTo({
						url:'/pages/login/login'
					})
				}else{
					uni.navigateTo({
						url: './myhome?id=' + id
					})
				}				
			},

		}
	}
</script>
